<template>
  <div> 
      <div>用户token：{{$store.state.user.token}}</div>
      <div>用户名：{{$store.state.setting.name}}</div>
      <div>mapGetters-token：{{token}}</div>
      <div>mapGetters-name：{{name}}</div>
      <!-- <button @click="updateToken">mapGetters修改token</button> -->
      <button @click="test1">直接调用修改token</button>
      <button @click="test">test方法修改token</button>
  </div>
</template>

<script>
import { mapGetters, mapMutations } from 'vuex'
export default {
    methods:{
    ...mapMutations(['updateToken', 'user/updateToken']),
        test1(){
            this.$store.commit('user/updateToken')
        },
         test() {
             this['user/updateToken']()
         }
    },
    computed: {
        ...mapGetters(['token', 'name'])
    }
}
</script>

<style>

</style>